package com.tool.completablefuture;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author niuyicong
 * @date 2024/10/21  17:28:03
 * @description
 */
public class FutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(new OurThread());
        Thread t1 = new Thread(futureTask, "t1");
        t1.start();
        String result = futureTask.get();
        System.out.println(result);
    }
}

class OurThread implements Callable<String>{
    @Override
    public String call() throws Exception {
        System.out.println("------come in call()  ");
        return "hello callable";
    }
}
